package com.hspedu.homework;

/**
 * @author sp
 * @version 0.1
 */
public class Homework04 {
    public static void main(String[] args) {
        Cellphone cellphone = new Cellphone();
        cellphone.testWork(new Computer() {
            @Override
            public double work(double n1, double n2) {
                return n1 + n2;
            }
        },1,2);
    }
}
/**
 * 1.计算机接口具有work()方法，功能是运算，有一个手机类Cellphone，
 *   定义方法testWork测试计算功能，调用接口的work方法
 * 2.要求调用Cellphone对象的testWork方法，使用上匿名内部类
 */

interface Computer{
    public double work(double n1, double n2);
}

class Cellphone{
    public void testWork(Computer computer, double n1, double n2){
        double result = computer.work(n1,n2);
        System.out.println("计算的结果是："+ result );
    }
}